-
Notifications
You must be signed in to change notification settings - Fork 15.4k
[CIR][NFC] Rename AtomicFence to AtomicFenceOp #171248
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This fixes missed suffix `Op` of `CIR_AtomicFence` defination
|
@llvm/pr-subscribers-clang Author: Haocong Lu (Luhaocong) ChangesThis fixes missed suffix Full diff: https://github.com/llvm/llvm-project/pull/171248.diff 3 Files Affected:
diff --git a/clang/include/clang/CIR/Dialect/IR/CIROps.td b/clang/include/clang/CIR/Dialect/IR/CIROps.td
index fcc7585cf81a5..e39bc31c3eafa 100644
--- a/clang/include/clang/CIR/Dialect/IR/CIROps.td
+++ b/clang/include/clang/CIR/Dialect/IR/CIROps.td
@@ -5493,7 +5493,7 @@ def CIR_AtomicClearOp : CIR_Op<"atomic.clear"> {
}];
}
-def CIR_AtomicFence : CIR_Op<"atomic.fence"> {
+def CIR_AtomicFenceOp : CIR_Op<"atomic.fence"> {
let summary = "Atomic thread fence";
let description = [{
C/C++ Atomic thread fence synchronization primitive. Implements the builtin
diff --git a/clang/lib/CIR/CodeGen/CIRGenBuiltin.cpp b/clang/lib/CIR/CodeGen/CIRGenBuiltin.cpp
index 16c006df6853e..c7040b14f5ef1 100644
--- a/clang/lib/CIR/CodeGen/CIRGenBuiltin.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenBuiltin.cpp
@@ -60,9 +60,9 @@ static RValue emitBuiltinBitOp(CIRGenFunction &cgf, const CallExpr *e,
return RValue::get(result);
}
-static mlir::Value makeAtomicFenceValue(CIRGenFunction &cgf,
- const CallExpr *expr,
- cir::SyncScopeKind syncScope) {
+static mlir::Value makeAtomicFenceOpValue(CIRGenFunction &cgf,
+ const CallExpr *expr,
+ cir::SyncScopeKind syncScope) {
CIRGenBuilderTy &builder = cgf.getBuilder();
mlir::Value orderingVal = cgf.emitScalarExpr(expr->getArg(0));
@@ -80,7 +80,7 @@ static mlir::Value makeAtomicFenceValue(CIRGenFunction &cgf,
auto ordering = static_cast<cir::MemOrder>(constOrderingAttr.getUInt());
- cir::AtomicFence::create(
+ cir::AtomicFenceOp::create(
builder, cgf.getLoc(expr->getSourceRange()), ordering,
cir::SyncScopeKindAttr::get(&cgf.getMLIRContext(), syncScope));
@@ -1012,10 +1012,10 @@ RValue CIRGenFunction::emitBuiltinExpr(const GlobalDecl &gd, unsigned builtinID,
return errorBuiltinNYI(*this, e, builtinID);
case Builtin::BI__atomic_thread_fence:
return RValue::get(
- makeAtomicFenceValue(*this, e, cir::SyncScopeKind::System));
+ makeAtomicFenceOpValue(*this, e, cir::SyncScopeKind::System));
case Builtin::BI__atomic_signal_fence:
return RValue::get(
- makeAtomicFenceValue(*this, e, cir::SyncScopeKind::SingleThread));
+ makeAtomicFenceOpValue(*this, e, cir::SyncScopeKind::SingleThread));
case Builtin::BI__c11_atomic_thread_fence:
case Builtin::BI__c11_atomic_signal_fence:
case Builtin::BI__scoped_atomic_thread_fence:
diff --git a/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp b/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp
index 97bd3cf850daa..c8b395b1feb93 100644
--- a/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp
+++ b/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp
@@ -860,8 +860,8 @@ mlir::LogicalResult CIRToLLVMAtomicClearOpLowering::matchAndRewrite(
return mlir::success();
}
-mlir::LogicalResult CIRToLLVMAtomicFenceLowering::matchAndRewrite(
- cir::AtomicFence op, OpAdaptor adaptor,
+mlir::LogicalResult CIRToLLVMAtomicFenceOpLowering::matchAndRewrite(
+ cir::AtomicFenceOp op, OpAdaptor adaptor,
mlir::ConversionPatternRewriter &rewriter) const {
mlir::LLVM::AtomicOrdering llvmOrder = getLLVMMemOrder(adaptor.getOrdering());
|
|
@llvm/pr-subscribers-clangir Author: Haocong Lu (Luhaocong) ChangesThis fixes missed suffix Full diff: https://github.com/llvm/llvm-project/pull/171248.diff 3 Files Affected:
diff --git a/clang/include/clang/CIR/Dialect/IR/CIROps.td b/clang/include/clang/CIR/Dialect/IR/CIROps.td
index fcc7585cf81a5..e39bc31c3eafa 100644
--- a/clang/include/clang/CIR/Dialect/IR/CIROps.td
+++ b/clang/include/clang/CIR/Dialect/IR/CIROps.td
@@ -5493,7 +5493,7 @@ def CIR_AtomicClearOp : CIR_Op<"atomic.clear"> {
}];
}
-def CIR_AtomicFence : CIR_Op<"atomic.fence"> {
+def CIR_AtomicFenceOp : CIR_Op<"atomic.fence"> {
let summary = "Atomic thread fence";
let description = [{
C/C++ Atomic thread fence synchronization primitive. Implements the builtin
diff --git a/clang/lib/CIR/CodeGen/CIRGenBuiltin.cpp b/clang/lib/CIR/CodeGen/CIRGenBuiltin.cpp
index 16c006df6853e..c7040b14f5ef1 100644
--- a/clang/lib/CIR/CodeGen/CIRGenBuiltin.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenBuiltin.cpp
@@ -60,9 +60,9 @@ static RValue emitBuiltinBitOp(CIRGenFunction &cgf, const CallExpr *e,
return RValue::get(result);
}
-static mlir::Value makeAtomicFenceValue(CIRGenFunction &cgf,
- const CallExpr *expr,
- cir::SyncScopeKind syncScope) {
+static mlir::Value makeAtomicFenceOpValue(CIRGenFunction &cgf,
+ const CallExpr *expr,
+ cir::SyncScopeKind syncScope) {
CIRGenBuilderTy &builder = cgf.getBuilder();
mlir::Value orderingVal = cgf.emitScalarExpr(expr->getArg(0));
@@ -80,7 +80,7 @@ static mlir::Value makeAtomicFenceValue(CIRGenFunction &cgf,
auto ordering = static_cast<cir::MemOrder>(constOrderingAttr.getUInt());
- cir::AtomicFence::create(
+ cir::AtomicFenceOp::create(
builder, cgf.getLoc(expr->getSourceRange()), ordering,
cir::SyncScopeKindAttr::get(&cgf.getMLIRContext(), syncScope));
@@ -1012,10 +1012,10 @@ RValue CIRGenFunction::emitBuiltinExpr(const GlobalDecl &gd, unsigned builtinID,
return errorBuiltinNYI(*this, e, builtinID);
case Builtin::BI__atomic_thread_fence:
return RValue::get(
- makeAtomicFenceValue(*this, e, cir::SyncScopeKind::System));
+ makeAtomicFenceOpValue(*this, e, cir::SyncScopeKind::System));
case Builtin::BI__atomic_signal_fence:
return RValue::get(
- makeAtomicFenceValue(*this, e, cir::SyncScopeKind::SingleThread));
+ makeAtomicFenceOpValue(*this, e, cir::SyncScopeKind::SingleThread));
case Builtin::BI__c11_atomic_thread_fence:
case Builtin::BI__c11_atomic_signal_fence:
case Builtin::BI__scoped_atomic_thread_fence:
diff --git a/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp b/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp
index 97bd3cf850daa..c8b395b1feb93 100644
--- a/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp
+++ b/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp
@@ -860,8 +860,8 @@ mlir::LogicalResult CIRToLLVMAtomicClearOpLowering::matchAndRewrite(
return mlir::success();
}
-mlir::LogicalResult CIRToLLVMAtomicFenceLowering::matchAndRewrite(
- cir::AtomicFence op, OpAdaptor adaptor,
+mlir::LogicalResult CIRToLLVMAtomicFenceOpLowering::matchAndRewrite(
+ cir::AtomicFenceOp op, OpAdaptor adaptor,
mlir::ConversionPatternRewriter &rewriter) const {
mlir::LLVM::AtomicOrdering llvmOrder = getLLVMMemOrder(adaptor.getOrdering());
|
Lancern
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM after a nit.
| cir::SyncScopeKindAttr::get(&cgf.getMLIRContext(), syncScope)); | ||
|
|
||
| return {}; | ||
| return; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This return is unnecessary then.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
| CIRGenBuilderTy &builder = cgf.getBuilder(); | ||
| mlir::Value orderingVal = cgf.emitScalarExpr(expr->getArg(0)); | ||
|
|
||
| auto constOrdering = orderingVal.getDefiningOp<cir::ConstantOp>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a blocker for this PR, but to ensure compile-time constant folding a better way would be to rely on the clang constant evaluator instead:
std::optional<Expr::EvalResult> constOrdering;
if (Expr::EvalResult eval; expr->getArg(0)->EvaluateAsInt(eval, cgf.getContext()))
constOrdering.emplace(eval);
if (!constOrdering.has_value()) {
cgf.cgm.errorNYI("Variable atomic fence ordering");
return;
}
// ...There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am willing to improve the implementation and support non-const memory order later if nobody is doing this.
andykaylor
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
This fixes missed suffix
OpofCIR_AtomicFencedefination and also improves APImakeAtomicFenceValue.